//package com.zz.framework.core.base.actuator
//
//import com.zz.framework.core.entity.HttpResponse
//import com.zz.framework.core.entity.HttpStatus
//import com.zz.framework.core.ext.launchUI
//import kotlinx.coroutines.CoroutineScope
//
//
//open class RequestActuator<R>(private val viewModelScope: CoroutineScope) {
//
//    /**
//     *  最开始执行 block
//     */
//    private var startBlock: (() -> Unit)? = null
//
//    /**
//     *  成功 block, 返回值是 (R)
//     */
//    protected open var successBlock: ((R?) -> Unit)? = null
//
//    /**
//     *  成功 block, 返回值是 KResponse<R>
//     */
//    protected open var successRspBlock: ((HttpResponse<R>) -> Unit)? = null
//
//    /**
//     *  失败 block
//     */
//    protected open var failureBlock: ((HttpStatus) -> Unit)? =  {
//
//    }
//
//    protected var finallyBlock:(() -> Unit)? = null
//    /**
//     *  异常 block
//     */
//    protected open var exceptionBlock: ((Throwable?) -> Unit)? = null
//
//    fun onStart(block: () -> Unit) {
//        this.startBlock = block
//    }
//
//    fun request(block: suspend CoroutineScope.() -> HttpResponse<R>?) {
//        startBlock?.invoke()
//        viewModelScope.launchUI({
//            block()?.execute(successBlock, failureBlock)
//            block()?.executeRsp(successRspBlock, failureBlock)
//            finallyBlock?.invoke()
//        }, {
//            exceptionBlock?.invoke(it)
//        })
//    }
//
//    fun onSuccess(block: (R?) -> Unit) {
//        this.successBlock = block
//    }
//
//    fun onSuccessRsp(block: (HttpResponse<R>) -> Unit) {
//        this.successRspBlock = block
//    }
//
//    fun onFailure(block: (HttpStatus) -> Unit) {
//        this.failureBlock = block
//    }
//
//    fun onException(block: (Throwable?) -> Unit) {
//        this.exceptionBlock = block
//    }
//
//    fun onFinally(block: () -> Unit) {
//        this.finallyBlock = block
//    }
//}